package thread;

public class ForegroundBackgroundThread {
    public static void main(String[] args) {
        Thread thread=new Thread(()->{
            while(true) {
                System.out.println("hello thread");
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });
        thread.setDaemon(true);//把thread设为守护线程(后台线程),不能阻止进程结束
        thread.start();

        //
    }
}
